package collect.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestHashMap {
    public static void main(String[] args) {
        HashMap<Student, String> hashmap = new HashMap<>();
        Student stu1 = new Student("张三", 23, "男");
        Student stu2 = new Student("李四", 24, "男");
        Student stu3 = new Student("王五", 24, "男");
        Student stu4 = new Student("张三", 23, "男");
        hashmap.put(stu1, "重庆");
        hashmap.put(stu2, "陕西");
        hashmap.put(stu3, "贵州");
        hashmap.put(stu4, "云南");
        //获取键值对
        Set<Map.Entry<Student, String>> entries = hashmap.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            /*String name = key.getName();
            int age = key.getAge();*/
            System.out.println(key + "=" + value);
        }


    }
}
